#include<iostream>
#include<algorithm>
#include<vector>	
using namespace std;
typedef long long LL;
const int N = 2e5 + 10, MOD = 1000000007;
vector<int> arr;
vector<int> tree;
int n;
int b[10010];
int tree1[N];
int lowbit(int x)
{
	return x & (-x);
}
void add(int x, int v)
{
	for (int i = x; i <= N; i+=lowbit(i)) {
		tree1[i] += v;
	}
}
int query(int x)
{
	int sum = 0;
	for (int i = x; i; i -= lowbit(i)) {
		sum += tree1[i];
	}
	return sum;
}
int find(int x)
{
	int l = 0;
	int r = arr.size() - 1;
	while (l < r) {
		int mid = l + r >> 1;
		if (arr[mid] >= x) {
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}
	return l;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		arr.push_back(x);
	}
	sort(arr.begin(), arr.end());
	arr.erase(unique(arr.begin(), arr.end()),arr.end());
	cout << arr.size() << endl;
	for (int i = 0; i < arr.size(); i++) {
		tree.push_back(find(arr[i]));
	}
	for (int i = 0; i < arr.size(); i++) {
		cout << arr[i] << " ";
		cout << tree[i] << endl;
	}
	return 0;
}